fix(core): add real-world time budget to prevent infinite-loop event-driven agent state transitions#28389
Conversation
|
📊 PR Size: size/S
|
There was a problem hiding this comment.
Code Review
This pull request introduces a real-world time budget mechanism to GeminiClient to prevent zero-latency event flooding by propagating a deadline across stream-generation methods. If the deadline is exceeded, a LoopDetected event is yielded. The feedback points out that the default time budget of 5 seconds is too short for typical agent tasks (such as LLM generation or tool execution) and suggests increasing it to 5 minutes to prevent premature aborts.
| // Real-world time budget (ms) to protect against zero-latency event flooding | ||
| const DEFAULT_TIME_BUDGET_MS = 5000; |
There was a problem hiding this comment.
The default time budget of 5000ms (5 seconds) is extremely short for real-world agent executions. A single LLM generation or tool execution (e.g., running a build or test) can easily exceed 5 seconds, causing the agent to prematurely abort with a LoopDetected event. Consider increasing this default significantly (e.g., to 5 minutes / 300,000ms) to ensure robust execution of non-trivial tasks.
| // Real-world time budget (ms) to protect against zero-latency event flooding | |
| const DEFAULT_TIME_BUDGET_MS = 5000; | |
| // Real-world time budget (ms) to protect against zero-latency event flooding | |
| const DEFAULT_TIME_BUDGET_MS = 300000; |
close #28271